package rs.creator;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import rs.domain.Tag;
import rs.util.TagComparator;
import rs.util.TuningParameters;

/* Classe che, dato il vettore pesato dei tag, ne calcola i best rated. */
public class BestTags {
	
	public List<Tag> getTags(Map<String, Double> tags2weights) {
		List<Tag> tag_list = new ArrayList<Tag>();
		
		for (String t : tags2weights.keySet()) {
			tag_list.add(new Tag(t, tags2weights.get(t)));
		}
		Collections.sort(tag_list, new TagComparator());
		
		List<Tag> best_tags = new ArrayList<Tag>();
		for (int i = 0; i < TuningParameters.BEST_TAGS_LIMIT && i < tag_list.size(); i++) {
			best_tags.add(new Tag(tag_list.get(i).getName(), tag_list.get(i).getWeight()/tag_list.get(0).getWeight()));
		}
		
		return best_tags;
	}

}
